#include "stdafx.h"
#include "Sqlite3Database.h"

Sqlite3Database::Sqlite3Database(void) : Builder(nullptr),Connection(nullptr),Reader(nullptr)
{
};

Sqlite3Database::Sqlite3Database(System::String^ DataSource, bool IsFullPath)
{
	this->Builder = gcnew System::Data::SQLite::SQLiteConnectionStringBuilder();
	this->Builder->ToFullPath = IsFullPath;
	this->Builder->DataSource = DataSource;
	this->Connection = gcnew System::Data::SQLite::SQLiteConnection(this->Builder->ToString());
	this->Reader = nullptr;
};

Sqlite3Database::~Sqlite3Database()
{
	delete this->Builder;
	delete this->Connection;
	delete this->Reader;
};

System::Void Sqlite3Database::Connect()
{
	this->Connection->Open();
};

System::Void Sqlite3Database::Disconnect()
{
	this->Connection->Close();
};

bool Sqlite3Database::Query(System::String^ Sql)
{
	System::Data::SQLite::SQLiteCommand^ c = gcnew System::Data::SQLite::SQLiteCommand(Sql,this->Connection);
	this->Reader = c->ExecuteReader();
	if (this->Reader->HasRows) return true;
	else return false;
};